﻿using System.Collections.Generic;
using StudentInfo.Areas.StudentArea.ViewModels;
using System.Web.Mvc;

namespace StudentInfo.Areas.StudentArea.ViewModelHelpers
{
    public class MarkEditViewModelHelper
    {
        public static MarkEditViewModel PopulateMarkEditViewModel(Mark mark)
        {
            return new MarkEditViewModel
            {
                Id = mark.Id,
                StudentId = mark.StudentId,
                ExamId = mark.ExamId,
                Result = mark.Result
            };
        }

        public static Mark PopulateMarkFromEditViewModel(MarkEditViewModel model)
        {
            return new Mark
            {
                Id = model.Id,
                StudentId = model.StudentId,
                ExamId = model.ExamId,
                Result = model.Result
            };
        }

        public static void PopulateStudentList(MarkEditViewModel model, List<Student> studentList)
        {
            model.StudentList = new SelectList(studentList, "Id", "StudentName");
        }

        public static void PopulateExamList(MarkEditViewModel model, List<Exam> examList)
        {
            model.ExamList = new SelectList(examList, "Id", "ExamName");
        }
    }
}